/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beanAdmin;

import com.matrimonysite.entity.UserServicePackage;
import com.matrimonysite.sessionbean.UserServicePackageFacade;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author khanhnguyen
 */
@ManagedBean(name = "ManageUserServices")
@SessionScoped
public class ManageUserServices {

    @EJB
    private UserServicePackageFacade userServicePackageFacade;
    private UserServicePackage userServicePackage;
    List<UserServicePackage> userServicePackageList;

    public UserServicePackage getUserServicePackage() {
        return userServicePackage;
    }

    public void setUserServicePackage(UserServicePackage userServicePackage) {
        this.userServicePackage = userServicePackage;
    }

    /**
     * Creates a new instance of ManageUserServices
     */
    public ManageUserServices() {
        userServicePackage = new UserServicePackage();
        userServicePackageFacade = new UserServicePackageFacade();
    }

    public void creatUserServices() {
        Integer init = userServicePackage.getServiceID();
        userServicePackage.getServiceID();
        userServicePackage.getServiceName();
        userServicePackage.getDescription();
        userServicePackage.getPrice();

        userServicePackageFacade.create(userServicePackage);
    }

    public void editUserServices() {
        userServicePackageFacade.edit(userServicePackage);
        FacesContext face = FacesContext.getCurrentInstance();
        face.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Update services Success.", "Update services Success."));

    }

    public void deleteUserServices() {
        Integer init = userServicePackage.getServiceID();
        userServicePackage.setServiceID(init);
        userServicePackageFacade.remove(userServicePackage);
    }
    
    public List<UserServicePackage> getAllUserServicePackage(){
        return userServicePackageFacade.getAllUserServicePackage();
    }
}
